/*
 * @Descripttion: 
 * @version: 
 * @Author: TT
 * @Date: 2023-10-26 10:42:28
 * @LastEditors: TT
 * @LastEditTime: 2023-10-27 16:03:37
 */

import 'package:flutter/material.dart';
import 'package:hzy_project_template/commpontents/commpontents_index.dart';
import 'package:hzy_project_template/config/config_index.dart';
import 'package:hzy_project_template/pages/my/widgets/my_widget.dart';
import 'package:hzy_project_template/utils/utils_index.dart';
import 'package:hzy_project_template/base_ui_config/base_ui_config_index.dart';
class MyInfoV extends CommonGetXV<MyInfoC> {
  MyInfoV({Key? key}) : super(key: key);
  @override
  MyInfoC get controller => Get.put(MyInfoC());

  @override
  Widget createBody({
    required BuildContext context,
    BoxConstraints? constraints,
  }) {
    Widget body = Column(
      crossAxisAlignment: CrossAxisAlignment.center,
      children: [
        Gaps.vGap20,
        createUserHeaderInfoWidget(),
        Gaps.vGap10,
        Text(
          NoteLauncIdConfig.replaceAvatar.tr,
          style: FontConfig.fontMedium16Black,
        ),
        Gaps.vGap20,
        createUserInfoTopInfoWidget(),
      ],
    );
    body = SingleChildScrollView(
      child: body,
    );
    return body;
  }

  @override
  createFlexBleSpace() {
    return null;
  }

  /// 创建用户头像
  createUserHeaderInfoWidget() {
    Widget body = userImgGlobalSharingWidget(
      tapCallback: () {
        controller.tapShowHeaderImage();
      },
    );

    return body;
  }

  /// 创建用户重要信息
  createUserInfoTopInfoWidget() {
    Widget body = controller.myWidget.configUserInfoTopWidget(
      tapItemCallback: (itemModel, index) {
        controller.tapImportantUserInfo(
          itemModel: itemModel,
          type: index,
        );
      },
    );
    return body;
  }
}

class MyInfoC extends CommonGetXController {
  // --------- 属性 --------- //
  MyWidget myWidget = MyWidget();
  // --------- 生命周期  --------- //
  @override
  configDefault() {
    safeAreabottm = true;
  }
  // --------- 数据处理  --------- //

  // --------- 触发事件  --------- //
  /// 点击用户头像
  tapShowHeaderImage() async {
    await configChangeHeaderImage(
      maxAssets: 1,
      type: 1,
    );
  }

  /// 点击用户重要信息
  tapImportantUserInfo({
    required HzyNormalItemModel itemModel,
    int? type,
  }) {
    currentToPage(
      name: itemModel.router ?? "",
      arguments: type,
    );
  }
}
